package editor.cn;

import java.util.Arrays;

class Solution1184{
    public static void main(String[] args) {
        Solution solution = new Solution1184().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int distanceBetweenBusStops(int[] distance, int start, int destination) {
    //    技巧性很重的方法  如果面对的是2,1，那么就直接化成1,2即可，这是顺逆时针的常见处理方法:
        int sum=0;
        for (int i = Math.min(start,destination); i <Math.max(start,destination); i++) {
            sum+=distance[i];
        }
        return Math.min(sum, Arrays.stream(distance).sum()-sum);
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}












